import React, { Component, Fragment } from 'react';
import { Link } from 'react-router-dom';
import { connect } from 'react-redux';
import { actionCreators } from '../../store';

import { Descriptions } from 'antd';

class BasicInfo extends Component{
  state={
  };

  renderTaskType = (taskType) => {
    switch(taskType){
      case 0: return "执行一次";
      case 1: return "定时任务";
      default: return null;
    }
  }
  renderSchedulerType = (schedulerType) => {

  }

  render(){
    let { taskInfo } = this.props;
    if(JSON.stringify(taskInfo)!=='{}'){
      let basic = taskInfo.task;
      return (
        <Descriptions>
          <Descriptions.Item label="服务名称">{basic.taskName}</Descriptions.Item>
          <Descriptions.Item label="交换频率" span={2}>{this.renderTaskType(taskInfo.taskType)}</Descriptions.Item>
          {
            taskInfo.taskType==1?
            <Fragment>
              <Descriptions.Item label="是否重复">{basic.repeat?"重复":"不重复"}</Descriptions.Item>
              <Descriptions.Item label="定时类型">{this.renderSchedulerType(basic.schedulerType)}</Descriptions.Item>
            </Fragment>
            :null
          }
        </Descriptions>
      );
    }
    return null;
  }
}

const mapStateToProps = (state) => {
  return {
    taskInfo: state.getIn(['task','taskInfo']).toJS()
  }
}

const mapDispatchToProps = (dispatch) => ({
  
})

export default connect(mapStateToProps, mapDispatchToProps)(BasicInfo);